import { defineComponent } from 'vue';
import GLayout from '/@/shared/components/g-layout/index.vue';
import { SmileOutlined, DownOutlined } from '@ant-design/icons-vue';
export default defineComponent({
  components: { GLayout, SmileOutlined, DownOutlined },
  data() {
    return {
      columns: [] as any,
      data: [] as any,
    };
  },
  mounted() {
    this.init();
  },
  computed: {
    totals() {
      let totalBorrow = 0;
      let totalRepayment = 0;

      this.data.forEach(({ borrow, repayment }) => {
        totalBorrow += borrow;
        totalRepayment += repayment;
      });
      return { totalBorrow, totalRepayment };
    },
  },
  methods: {
    init() {
      this.columns = [
        {
          title: 'Name',
          dataIndex: 'name',
        },
        {
          title: 'Borrow',
          dataIndex: 'borrow',
        },
        {
          title: 'Repayment',
          dataIndex: 'repayment',
        },
      ];
      this.data = [
        {
          key: '1',
          name: 'John Brown',
          borrow: 10,
          repayment: 33,
        },
        {
          key: '2',
          name: 'Jim Green',
          borrow: 100,
          repayment: 0,
        },
        {
          key: '3',
          name: 'Joe Black',
          borrow: 10,
          repayment: 10,
        },
        {
          key: '4',
          name: 'Jim Red',
          borrow: 75,
          repayment: 45,
        },
      ];
    },
  },
});
